import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import router from 'umi/router';
import {Icon} from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import styles from '../Pbulic.less';


@connect()
export default class EquipmentDetail extends PureComponent {
  constructor(props) {
    super(props);
    this.state={
      detailTitle:null,
    }
  }


  componentDidMount() {

  }

  componentWillUnmount(){
    const { dispatch } = this.props;
    dispatch({
      type: `appversion/appendClearState`,
    })
  }




  // formatterMenu = (data) => {
  //   return data.reduce((arr, curr) => {
  //     if(curr.authority){
  //       if (checkPermissions(curr.authority)) {
  //         return arr.concat(curr);
  //       } else {
  //         return arr.concat([]);
  //       }
  //     }else{
  //       return arr.concat(curr);
  //     }
  //   }, []);
  //
  // };

  goBack = () => {
    const {location,} = this.props;
    router.push({ pathname:`/system/appversion/list`,  query: { ...location.query} });
  }

  render() {
    const { match, children } = this.props;

    //const location_arry = history.location.pathname.split("/");
    // const tabDefaultKeys = location_arry[location_arry.length - 1];
    const appversionId = match.params.id && match.params.id!='detail' ? match.params.id : 0;


    return (
      <Fragment>

        <Icon type="close-circle-o"  className={styles.close_icon} onClick={this.goBack}/>
          <PageHeaderLayout
            hiddenBreadcurmb={true}
            title={appversionId==0 ? '新增版本' : '版本编辑'}
          >
            {children}
          </PageHeaderLayout>
      </Fragment>
    );
  }
}
